echo off
rem jimgutil native 库 Android NDK 交叉编译脚本,创建Makefile
rem author guyadong

rem 检测是否安装NDK,没有安装NDK则报错退出
if not DEFINED ANDROID_NDK (
	echo "ERROR:environment variable ANDROID_NDK not define" && exit /B -1
	)
echo make feature_se VS2015 project
where cmake
if errorlevel 1 (
	echo cmake NOT FOUND.
	exit /B -1
)
echo cmake found
where java
if errorlevel 1 (
	echo java NOT FOUND.
	exit /B -1
)
echo java found
set sh_folder=%~dp0
pushd %sh_folder%..
rem 定义编译的版本类型(DEBUG|RELEASE)
set build_type=RELEASE
if "%1" == "DEBUG" set build_type=%1
echo build_type=%build_type%

rem 需要先编译feature_se
if exist native.ndk.prj rmdir native.ndk.prj /s/q
mkdir native.ndk.prj
pushd native.ndk.prj

set install_prefix=%sh_folder%release\jimgutil_android_armeabi

cmake %sh_folder% -G "Eclipse CDT4 - MinGW Makefiles" -DCMAKE_BUILD_TYPE=%build_type% ^
	-DCMAKE_INSTALL_PREFIX=%install_prefix% ^
	-DANDROID_ARM_NEON=ON ^
	-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake 

cmake --build . --target install --config release

if ERRORLEVEL 0 copy %install_prefix%\lib\libjimgutil_jni.so %sh_folder%..\jimgutil\src\main\resources\lib\armeabi-v7a

popd
popd
